fix: bound control-stream decompressor output against input size#21
Conversation
Invisible characters checkNo suspicious invisible characters detected in the PR diff. |
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approving: Cursor Bugbot completed with a skipped/neutral check and reported 1 unresolved finding (vector RLE output-ratio budget uses trailing bytes). Human review is needed before merge; no additional reviewers were assigned because the PR author is the sole repository collaborator.
Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 30fb134. Configure here.
There was a problem hiding this comment.
Stale comment
Risk: medium. Not approving: Cursor Bugbot check skipped and reported 1 unresolved finding (control-stream RLE output-ratio budget uses full input slice length). Human review is needed before merge; no additional reviewers were assigned because the PR author is the sole repository collaborator.
Sent by Cursor Approval Agent: Pull Request Router and Approver
Co-authored-by: minagishl <minagishl@users.noreply.github.com>
Co-authored-by: minagishl <minagishl@users.noreply.github.com>
There was a problem hiding this comment.
Risk: medium. Not approving: Cursor Bugbot check passed on the latest commit but no corresponding Bugbot review comment was found for HEAD. Human review is needed before merge; no additional reviewers were assigned because the PR author is the sole repository collaborator.
Sent by Cursor Approval Agent: Pull Request Router and Approver



Summary
DEFAULT_MAX_DECODE_OUTPUT_RATIO(1024) andcheck_decode_output_bytesso decompressors reject cumulative output larger thaninput_len * ratio(capped byDEFAULT_MAX_DECODE_COUNT)decode_u64_rle/decode_i64_rle)Related Issue
Closes #2
Type of Change
Testing
cargo test— all 75 tests passcargo fmt --allcargo clippy --all-targets --all-featurescontrol_stream_rle_rejects_decompression_bomb,control_stream_huffman_rejects_decompression_bomb,control_stream_fse_rejects_decompression_bomb,wire_extend_repeat_rejects_output_ratio_bombChecklist
Note
Medium Risk
Security-focused decode hardening across multiple decompressors; behavior change rejects previously accepted malicious inputs but should not affect valid payloads within the ratio cap.
Overview
Adds output-ratio limits on decode paths so tiny compressed payloads cannot expand into huge in-memory buffers (decompression bombs).
Wire layer: Introduces
DEFAULT_MAX_DECODE_OUTPUT_RATIO(1024),max_decode_output_bytes,check_decode_output_bytes, andextend_repeat_with_budget, which rejects cumulative output aboveinput_len × ratio(capped byDEFAULT_MAX_DECODE_COUNT).extend_repeatnow delegates to the budgeted helper.Decoders: Vector RLE (
decode_u64_rle/decode_i64_rle) parses runs first, then expands using only bytes consumed for the RLE header as the budget—not the full column buffer. Control-stream RLE, Huffman, and FSE apply the same checks; Huffman/FSE also pre-check declared output length and capVeccapacity.API: Re-exports
DEFAULT_MAX_DECODE_OUTPUT_RATIOfrom the crate root.Tests: Regression coverage for ratio bombs on wire helpers, vector RLE (including trailing junk bytes), and control-stream RLE/Huffman/FSE via
TwilicCodec.Reviewed by Cursor Bugbot for commit 0a5c455. Bugbot is set up for automated code reviews on this repo. Configure here.